package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.DestinationFilter;
import cn.wolfcode.luowowo.article.mapper.DestinationFilterMapper;
import cn.wolfcode.luowowo.article.query.DestinationFilterQuery;
import cn.wolfcode.luowowo.article.service.IDestinationFilterService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class DestinationFilterServiceImpl implements IDestinationFilterService {
    @Autowired
    private DestinationFilterMapper destinationFilterMapper;

    @Override
    public PageInfo query(DestinationFilterQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(destinationFilterMapper.selectForList(qo));
    }

    @Override
    public void saveOrUpdate(DestinationFilter destinationFilter) {
        if(destinationFilter.getId() == null){
            destinationFilterMapper.insert(destinationFilter);
        }else{
            destinationFilterMapper.updateByPrimaryKey(destinationFilter);
        }
    }

    @Override
    public List<DestinationFilter> list() {
        return destinationFilterMapper.selectAll();
    }
}
